package net.es.weathermap.topo.ps;

import java.io.IOException;

import edu.internet2.perfsonar.PSException;
import edu.internet2.perfsonar.TSLookupClient;
import org.apache.commons.httpclient.HttpException;
import org.jdom.Element;

public class PSTopoPuller {

    public Element pullTopology() throws HttpException, IOException, PSException {
        String[] tsList = new String[1];
        tsList[0] = "http://ps1.es.net:8012/perfSONAR_PS/services/topology";
        TSLookupClient psClient = new TSLookupClient();
        psClient.setTSList(tsList);
        Element domain = psClient.getDomain("urn:ogf:network:domain=ps.es.net", "http://ogf.org/schema/network/topology/base/20070828/");
        if (domain == null) {
            throw new IOException("No domain data from topology server");
        }
        return domain;
    }
}
